<%@ page language="java" import="java.util.*" pageEncoding="utf-8"
	isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
    String path = request.getContextPath();
			String basePath = request.getScheme() + "://"
					+ request.getServerName() + ":" + request.getServerPort()
					+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
	.input-group-btn:last-child>.btn{
		height:40px;
	}
</style>
<script type="text/javascript" src="<%=request.getContextPath()%>/easyui/jquery.min.js"></script>
<link href="<%=request.getContextPath()%>/css/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/jPages.css">
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/animate.css">
<script src="<%=request.getContextPath()%>/js/jPages.js"></script>

<link rel="stylesheet" href="<%=request.getContextPath()%>/css/fileinput.min.css">
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/bootstrap.min.css">
<link rel="stylesheet" href="<%=request.getContextPath()%>/umeditor/themes/default/css/umeditor.css">
<script src="<%=request.getContextPath()%>/js/jquery-3.2.1.min.js"></script>
<script src="<%=request.getContextPath()%>/js/bootstrap.min.js"></script>
<script src="<%=request.getContextPath()%>/js/jquery-bootstrap-pagination.js"></script>
<script src="<%=request.getContextPath()%>/js/fileinput.min.js"></script>
<script src="<%=request.getContextPath()%>/js/zh.js"></script>
 <!--ueditor插件js-->
<script type="text/javascript" src="<%=request.getContextPath()%>/umeditor/third-party/template.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/umeditor/umeditor.config.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/umeditor/umeditor.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/umeditor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
   		$("#upload")
		.fileinput(
				{
					uploadUrl : "/htx-backer/upload/photoImg",
					uploadAsync : true,
					maxFileCount : 1,
					initialPreview : [
							'<img src="${help.helpImg}" id="img" class="file-preview-image" width="320px" height="180px" />', ]
				})
		.on(
				'fileuploaded',
				function(event, data, previewId, index) {
					var form = data.form, files = data.files, extra = data.extra, response = data.response, reader = data.reader;
					if (response.data != null && response.data != "") {
						$("input[name=hidd]").val(response.data.purl);
					} else {
						alert("图片服务器异常，请重新上传！");
					}
				});
   	})
</script>
</head>
<body>
	<div class="place" style="margin-top:-10px;">
		<span>位置：</span>
		<ul class="placeul">
			<li><ema href="javascript:void">首页</em></li>
			<li><ema href="javascript:void">图片管理</em></li>
			<li><ema href="javascript:void">编辑发现轮播图</em></li>
		</ul>
	</div>
	<c:forEach items="${lists}" var="data">
	<div class="rightinfo">
		<div class="tools">
			<table>
				<tr>
					<td>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong style="font-weight: bolder;font-size: 12px;">启用/禁用</strong>
						<select class="statu">
							<option>${data.is_ban}</option>
							<option>禁用</option>
							<option>启用</option>
						</select>
					</td>
					<td>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong style="font-weight: bolder;font-size: 12px;">图片所在位置</strong>
						<select class="address">
							<option>${data.position_id}</option>
							<option>1</option>
							<option>2</option>
							<option>3</option>
							<option>4</option>
							<option>5</option>
							<option>6</option>
							<option>7</option>
							<option>8</option>
						</select>
					</td>
				</tr>
			</table> 
		</div>
	</div>
	
	<ul class="forminfo">
    <input type="hidden" name="hidd"></input><input type="hidden" name="imgid" value="${data.id}"></input>
          <strong>原始图片</strong><img src="${data.image_url}" id="imgId" height="200px" width="300px" style="margin-bottom:20px;"/></br>
    <tr>
		<td align="right"><strong>更换图片(支持jpg/png)宽750*高300</strong></td>
		<td><input id="upload" type="file" name="file" multiple
			class="file-loading"> <input id="url" name="helpImg"
			type="hidden"></td>
	</tr>
	<tr><strong>链接地址：</strong><input name="link" type="text" class="dfinput" value="${data.image_link}" style="font-size:13;width:500px;"/></tr>
    </ul>
    </c:forEach>
    <div style="margin-left:400px;"><input name="" type="button" class="tijiao" value="提交" style="width:96px; height:35px; line-height:35px; color:#fff; background:red; font-size:14px; font-weight:bold;border-radius: 3px; cursor:pointer;"/>
    &nbsp;<input name="quxiao" type="button" class="cancel" value="取消" /></div>
   	<div class="tip">
		<div class="tiptop">
			<span>提示信息</span>
		</div>
		<div class="tipinfo">
			<span><img src="<%=request.getContextPath()%>/images/ticon.png" /></span>
			<div class="tipright">
				<p>添加成功!</p>
				<cite>点击确定启动页 。</cite>
			</div>
		</div>
		<div class="tipbtn">
			<input name="" type="button" class="sure" value="确定"/>&nbsp;<input name="" type="button" class="cancel" value="取消" />
		</div>
	</div>
    <script type="text/javascript">
   		$(document).ready(function(){
   			$("input[name=quxiao]").click(function(){
	   			window.location.href="/htx-backer/selectSlideshowList?type=1";
	   		});
   			
   			var image_url = null;
    		$(".tijiao").click(function(){
    			image_url = $("input[name=hidd]").val();
    			if(image_url == null || image_url == ""){
    				image_url = $("#imgId")[0].src;
    			}
    			var image_link = $("input[name=link]").val();
    			if(image_link == null || image_link == ""){
    				alert("请填写链接地址");
    				return;
    			}
    			var id = $("input[name=imgid]").val();
    			var is_ban = $(".statu").find("option:selected").text();
    			var position_id = $(".address").find("option:selected").text();
   	    		$.ajax({
   	   				type:"get",
   	   				url:"/htx-backer/updateImageInfo", 
   	   				data:{
   	   					id:id,
   	   					image_link:image_link,
   	   					image_url:image_url,
   	   					is_ban:is_ban,
   	   					position_id:position_id
   	   				},
   	   				dataType:"json",
   	   				success:function(data){
   	   					var flag = data.flag;
   	   					if(flag == 1){
   	   					 	var btn = confirm("修改成功,点击确定发现轮播图!")
   	   					 	if(btn == true){
					   			window.location.href="/htx-backer/selectSlideshowList?type=1";
   	   					 	}
   	   					}
   	   				}
   				}) 
    		})
    	})
    </script>
</body>
</html>
